<?php
namespace Home\Controller;
use Think\Controller;
class UserController extends  Controller {
    public function login(){
        $this->display();
    }
    public function register(){

        $user = new \Model\UserModel();
        if(!empty($_POST)){
            $z = $user->create();
            if(!$z){
               print_r($user->getError());
                exit;
            }else{
                $user -> user_hobby = implode(',',$_POST['user_hobby']);
                $rst = $user->add();
                if($rst){
                    $this -> success('注册成功',U('Index/index'));//跳到首页
                }else{
                    $this -> error('注册失败',U('Index/index'));//跳首页
                }
            }

        }else{
            $this->display();
        }

    }
}